package com.scott.ch020.add.ch04;

import com.scott.utils.ZooKeeperConnectionUtil;
import org.apache.curator.framework.CuratorFramework;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class CreateNodeWithParent {


    private CuratorFramework connection;

    @Before
    public void init() {
        connection = ZooKeeperConnectionUtil.getConnectionBeginWithNamespace();
        System.out.println(connection);
    }


    @Test
    public void test() throws Exception {

        // 创建多级节点
        // 如果父节点不存在，则创建父节点
        String rs  =connection.create().creatingParentsIfNeeded().forPath("/app4/p1");
        System.out.println(rs);
    }

    @After
    public void closeConnection (){
        if(null != connection){
            connection.close();
        }
    }
}
